import 'package:base_lib/index.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';

class GoodAtPage extends BaseThemeWidget {
  final Parameters parameters;

  GoodAtPage(this.parameters) {
    info = parameters?.getString("goodAt") ?? "";
  }

  String info;

  @override
  Widget buildChild(BuildContext context, MTheme theme) {
    return Scaffold(
      appBar: AppBar(
        leading: BackButton(
          onPressed: () {
            Routers.pop(context);
          },
        ),
        centerTitle: true,
        title: Text("擅长"),
        actions: [
          FlatButton(
              onPressed: () {
                doSave(context);
              },
              textColor: Colors.white,
              child: Text("保存"))
        ],
      ),
      body: Container(
        color: Colors.white,
        child: Column(
          children: [
            Container(
              padding: EdgeInsets.all(10),
              margin: EdgeInsets.all(5),
              child: TextField(
                maxLines: 6,
                maxLength: 200,
                decoration: InputDecoration(
                  filled: true,
                  fillColor: theme.themeColor.themeBgColor,
                  border: InputBorder.none,
                  hintText: "请简单介绍",
                ),
                controller: TextEditingController(text: info),
                onChanged: (str) {
                  info = str;
                },
              ),
            ),
            Spacer()
          ],
        ),
      ),
    );
  }

  void doSave(context) {
    if (info.isEmpty) {
      ToastUtil.error("请输入擅长内容");
      return;
    }

    Routers.pop(context, info);
  }
}
